<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // Function Object String....

    new Function()
    new Object()
    new xxx()


    /* 手写instanceof */
    function Person() {
      
    }
    const p = new Person()
    console.log(p instanceof Person) // true
    console.log(p instanceof Object) // true
    console.log(p instanceof Function) // false
    console.log(Object instanceof Function) // 
    console.log(Object instanceof Object) // 

    // 所有函数和函数的实例都 instanceof Object 
    // 所有函数 instanceof Function 
    // Function.prototype.__proto__ = Object.prototype

    /* 
    Type.prototype是为obj原型链上的某个原型对象
    */
    function myInstanceOf(obj, Type) {
      // return obj.__proto__===Type.prototype
      let protoObj = obj.__proto__
      while (protoObj) {
        if (protoObj===Type.prototype) return true

        protoObj = protoObj.__proto__
      }
      return false
    }

    console.log(myInstanceOf(p, Person))
    console.log(myInstanceOf(p, Object))
    console.log(myInstanceOf(p, Function))





  </script>
</body>
</html>